﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        博客后台管理系统
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="~/Areas/Back/css/x-admin.css" media="all">
    <script src="~/Areas/Back/lib/layui/layui.js"></script>
    <script type="text/javascript" src="~/Areas/Back/js/x-layui.js"></script>
</head>
<body>
    <form id="recForm" class="layui-form" onsubmit="return false;">
        <div class="layui-form-item">
            <label class="layui-form-label">上传图片</label>
            <div class="layui-input-block">
                <input id="uploadImg" type="file" name="file1">
                <input id="photoUrl" name="PicUrl" type="text" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">照片描述</label>
            <div class="layui-input-block">
                <textarea id="taCont" name="Cont" placeholder="请输入照片的描述信息" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block" style="width:150px;">
                <button class="layui-btn" onclick="savePhoto()">提交保存</button>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <img id="imgPhoto" class="layui-upload-img" style="width:180px; height:140px" />
            </div>
        </div>
    </form>
    <script>
        layui.use(['upload', 'layer'], function () {
            var upload = layui.upload;
            var layer = layui.layer;
            var $ = layui.$;

            //执行实例
            var uploadInst = upload.render({
                elem: '#uploadImg' //绑定元素
              , url: '/Back/Gallery/UploadPhoto' //上传接口
              , done: function (res) {
                  //上传完毕回调
                  if (res.Success) {
                      $("#photoUrl").val(res.Remark);
                      $("#imgPhoto").attr("src", "/" + res.Remark);
                      layer.msg("上传成功");
                  }
                  else {
                      layer.msg("上传失败");
                  }
              }
            });
        });
    </script>
</body>
</html>